#define _CRT_SECURE_NO_WARNINGS  1

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct stu
{
	char name[10];
	int age;
};

int cmp_age(const void* e1, const void* e2)
{
	return ((struct stu*)e1)->age - ((struct stu*)e2)->age;
}

int cmp_name(const void* e1, const void* e2)
{
	return strcmp(((struct stu*)e1)->name,((struct stu*)e2)->name);
}

int main()
{
	int arr[] = {1,4,5,6,8,9,7};
	struct stu arr2[3] = { {"xiaoming",20},{"limingyy",29},{"huahuayy",18} };
	struct stu* p = arr2;
	int sz = sizeof(arr2) / sizeof(arr2[0]);
	qsort(arr2,sz,sizeof(arr2[0]),cmp_name);
	for (p = arr2; p < &arr2[sz]; p++)
	{
		printf("%s,%d ", (*p).name, (*p).age);
	}
	return 0;
}